import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css'
import pinia from './store/index'
import router from './router/index'
import { useUserStore } from './store/user'
import { checkEnvConfig } from './utils/env-validator'
import { setupGlobalErrorHandler } from './utils/errorHandler'

import { ConfigProvider } from 'ant-design-vue'
import zhCN from 'ant-design-vue/es/locale/zh_CN'

const app = createApp(App)

// 全局配置国际化
app.use(ConfigProvider, {
  locale: zhCN
})

app.use(pinia)
app.use(Antd)
app.use(router)

// 检查环境配置
checkEnvConfig()

// 初始化用户状态
const userStore = useUserStore()
userStore.initUserState()

// 设置全局错误处理器
setupGlobalErrorHandler()

app.mount('#app')
